import { isPhone } from "@pureadmin/utils";
import type { FormRules } from "element-plus";
import { reactive } from "vue";
/** 自定义表单规则校验 */
export const formRules = reactive(<FormRules>{
  name: [{ required: true, message: "请输入", trigger: "blur" }],
  fileJson: [{ required: true, message: "请上传文件", trigger: "change" }],
  contact: [
    {
      required: true,
      validator: (rule, value, callback) => {
        if (value === "") {
          callback(new Error("请输入"));
        } else if (!isPhone(value)) {
          callback(new Error("请输入正确的手机号码格式"));
        } else {
          callback();
        }
      },
      trigger: "change"
    }
  ]
});
